package com.yonder.gocommand.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.SessionAttributes;

import com.yonder.gocommand.entity.User;
import com.yonder.gocommand.service.IUserService;

@Controller
@SessionAttributes
@RequestMapping("/")
public class AddUserController {
	
	@Autowired
	IUserService userService;

	@RequestMapping(value = "/createUser", method = RequestMethod.POST)
	public void createUser(@ModelAttribute("user") User user, BindingResult result) {
		
		userService.saveOrUpdate(user);

		System.out.println("First Name:" + user.getFirstName() + "Last Name:" + user.getLastName());
		
	}

/*	@RequestMapping("/contacts")
	public ModelAndView showContacts() {

		return new ModelAndView("contact", "command", new Contact());
	}*/

}
